﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace QunYing.BLL
{
    public partial class DeviceRealTimeInfo
    {
        /// <summary>
        /// 获得数据列表(每天一笔)
        /// </summary>
        public DataSet GetListByOne(string strWhere)
        {
            return dal.GetListByOne(strWhere);
        }
         /// <summary>
        /// 获得报警信息CS
        /// </summary>
        public DataSet GetWarnForCS(string Dealer, DateTime time, bool isDealer)
         {
             return dal.GetWarnForCS(Dealer, time, isDealer);
         }
        /// <summary>
        /// 获得报警信息CS
        /// </summary>
        public DataSet GetAllWarnForCS(string Dealer, DateTime time, bool isDealer)
        {
            return dal.GetAllWarnForCS(Dealer, time, isDealer);
        }
        /// <summary>
        /// 报警信息
        /// </summary>
        /// <param name="strUserName"></param>
        /// <returns></returns>
        public DataTable QueryWarn(string strUserName, string strIcsa, DateTime startDate, DateTime endDate)
        {
            return dal.QueryWarn(strUserName, strIcsa, startDate, endDate);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public QunYing.Model.DeviceRealTimeInfo GetModel(string ID, string time)
        {
            return dal.GetModel(ID, time);
        }

        /// <summary>
        /// 获得图表信息
        /// </summary>
        public DataTable GetChartData(string strICSA, DateTime startDate, DateTime endDate)
        {
            return dal.GetChartData(strICSA, startDate, endDate);
        }

        /// <summary>
        /// 经销商获取报警信息
        /// </summary>
        /// <param name="DealerID">经销商编号</param>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <param name="province">所在城市</param>
        /// <param name="strState">处理状态</param>
        /// <returns></returns>
        public DataTable QueryDealerWarn(string DealerID, DateTime startDate, DateTime endDate, string strCity, string strState)
        {
            return dal.QueryDealerWarn(DealerID, startDate, endDate, strCity, strState);
        }

        /// <summary>
        /// 经销商主页报警信息
        /// </summary>
        /// <param name="strUserName"></param>
        /// <returns></returns>
        public DataTable QueryDealerIndexWarn(string DealerID, int num)
        {
            return dal.QueryDealerIndexWarn(DealerID, num);
        }

        /// <summary>
        /// 接警自动填写信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DataTable P_QueryAutoWarnInfo(string id)
        {
            return dal.P_QueryAutoWarnInfo(id);
        }

        /// <summary>
        /// 更新处理状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="state"></param>
        /// <param name="orderID"></param>
        /// <returns></returns>
        public bool UpdateState(string id, string state, string orderID)
        {
            return dal.UpdateState(id, state, orderID);
        }

        public void ChangedState(string sendTele)
        {
          var v =  this.GetModelList(string.Format("发送号码='{0}' and (告警是否解除=0  or (告警是否解除 is null))", sendTele));
          foreach (var vvv in v)
          {
              vvv.告警是否解除 = true;
              vvv.告警解除时间 = DateTime.Now;
              this.Update(vvv);
          }
        }

        /// <summary>
        /// 报警数量统计
        /// </summary>
        /// <param name="DealerID"></param>
        /// <returns></returns>
        public DataSet QueryWarnChart(string DealerID, DateTime startDate, DateTime endDate, string isDealer)
        {
            return dal.QueryWarnChart(DealerID, startDate, endDate, isDealer);
        }
    }
}
